<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
{include file="base/header" /}
<br/>
<div style="width: 500px;margin: 0 auto;margin-top: 150px;">
    <form class="layui-form" action="" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label"  style="width: 100px">订单号</label>
            <div class="layui-input-block">
                <input type="text" name="postid" readonly required value="{$id}" lay-verify="required" placeholder="订单号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px">损坏数量</label>
            <div class="layui-input-block">
                <input type="text" name="number" required  lay-verify="required" placeholder="损坏数量(个)" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" onclick="sub()" class="btn btn-primary">立即添加</button>
            </div>
        </div>
    </form>
</div>
</body>
<script>
    function sub() {
        var num = $("input[name=number]").val();
        var postid = $("input[name=postid]").val();
        if(!num){
            layer.alert('请填写损坏个数');
            return ;
        }
        $.ajax({
            url:"{:url('index/shop/postdamagenum')}",
            data:"num="+num+"&postid="+postid,
            type:"post",
            dataType:"json",
            success:function (res) {
                if(res.success){
                    layer.alert(res.success);
                    return;
                }
                if(res.error){
                    layer.alert(res.error);
                    return;
                }
            }
        });
    }
</script>
</html>